LGF_SimpleAveraging (FB / 1.0.0)

Overview

Author: Siemens Digital Industry

Short description

This function calculates a moving arithmetic mean from LReal values.
The method can be used to smooth data series; the values can be read in cyclically or triggered.

Block Interface

LGF_SimpleAveraging (FB)
Bool  cyclicExecution average  LReal
    
Bool  trigger overflow  Bool
    
Bool  reset   
    
LReal  value   
    
USInt  windowSize   
    
   

Input parameter

IdentifierData type Default value Description
cyclicExecutionBool FALSE TRUE: cyclic operation, trigger not in use
triggerBool FALSE Rising edge: Read in `value` with every pulse at input `trigger`
resetBool FALSE TRUE: The block is reset and the calculation starts again.
valueLReal 0.0 Value/s from which the moving average is to be determined.
windowSizeUSInt 5 Window length for averaging in the range from 1..255

Output parameter

IdentifierData type Description
averageLReal Moving / Floating average
overflowBool TRUE: Overflow detected in the calculation

Functional description

Note
The block LGF_SimpleAveraging does not query the data type for the input parameter value. For data types other than LReal, either an implicit conversion is performed automatically or an error is generated during compilation.
You can find further information in the Chapter “Overview of Data Type Conversion” in the Online Help section of the TIA Portal or under:
https://support.industry.siemens.com/cs/ww/en/view/109773506/100611494667

The block calculates the (moving) average based on the set windowSize. If windowSize is set to windowSize < 1, the value is passed through without averaging.

There are two options for reading the values:

If the calculation reaches the value range limits of LReal, the output overflow is set.

Change log

Version & DateChange description
1.0.0Simatic Systems Support
18.07.2024First Release